import { ApiCall } from "tsrpc";
import { queue } from "sharp";
import MarketManage from "../../core/manage/MarketManage";
import { panel_common } from "../../shared/face";
import sdk from '../../core/index';
import { ReqInfo, ResInfo } from "../../shared/api_client/market/PtlInfo";

export default async function (call: ApiCall<ReqInfo, ResInfo>) {
    // TODO
    let item = MarketManage.list.find((val,idx)=>{return val._id == call.req.id})
    if(!item){
        call.error('商品已不存在');
        return;
    }
    let res = {
        _id: item._id,
        name: item.item.name,
        emoji: item.item.emoji,
        icon:  item.item.icon || 'https://shadow.elemecdn.com/app/element/hamburger.9cf7b091-55e9-11e9-a976-7f4d0b07eef6.png',
        id: item.item.id,
        quality:'SSR',
        desc: item.item.desc,
        type: item.item.type,
        count: item.item.count,
        atts: [],
        put_id: item.put_id,
        put_time: item.put_time,
        sell_price: item.sell_price
    }
    let card = sdk.tool.card.create2();
card.title('道具详细');
sdk.prop.client_lookitemV2(item.item,card);
card.l('出售数量',item.item.count)
card.l('出售价格',item.sell_price)
card.l('上架时间',sdk.tool.common.timestampToTime(item.put_time))


    call.succ({
        id: item._id,
        info2: card.resData
    })
}
